Skip to content

feat(minibf): implement /epochs/{number}/stakes endpoint - #1152

Merged
scarmuega merged 1 commit into
mainfrom
mmahut/epoch-stakes
Aug 13, 2026
Merged

feat(minibf): implement /epochs/{number}/stakes endpoint#1152
scarmuega merged 1 commit into
mainfrom
mmahut/epoch-stakes

Conversation

@mmahut

@mmahut mmahut commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Resolves #1082.

Implements /epochs/{number}/stakes (#1082).

Serves the per-account stake distribution from the account-stakes log added in the base PR. One key-range scan per page, Blockfrost pagination (count/page), 404 above the current epoch, zero-amount rows filtered out to match dbsync.

Verified against hosted Blockfrost on preview and the known gap: the current epoch returns [] until its RUPD emission lands, so we lag hosted Blockfrost by one epoch. A follow-up can close this by emitting from the mark snapshot as well. Epochs before the node's sync start have no rows.

Summary by CodeRabbit

  • New Features

    • Added an endpoint to retrieve stake distributions for a specific epoch.
    • Supports pagination and returns stake addresses, pool IDs, and associated amounts.
    • Excludes zero-stake entries from results.
    • Provides clear handling for invalid, future, empty, or unavailable epochs.
  • Documentation

    • Documented the new epoch stakes endpoint in the Mini Blockfrost API coverage.

@mmahut
mmahut requested a review from scarmuega as a code owner July 31, 2026 22:25
@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5b75d52d-78fd-4039-b9d3-a6b40843785a

📥 Commits

Reviewing files that changed from the base of the PR and between e88bae1 and 9b37f9f.

📒 Files selected for processing (5)
  • crates/minibf/src/lib.rs
  • crates/minibf/src/routes/epochs/mod.rs
  • crates/minibf/src/test_support.rs
  • crates/testing/src/synthetic.rs
  • docs/content/apis/minibf.mdx

📝 Walkthrough

Walkthrough

Adds the Mini Blockfrost /epochs/{epoch}/stakes endpoint. The handler validates epochs, reads account stake logs, filters and paginates results, maps credentials and pool IDs, and returns stake responses. Synthetic fixtures, tests, and API documentation were added.

Changes

Epoch stake distribution

Layer / File(s) Summary
Account stake log fixtures
crates/testing/src/synthetic.rs, crates/minibf/src/test_support.rs
Adds account stake log seeding for positive and zero-balance entries. Test setup seeds the prior epoch and exposes the generated tip epoch.
Epoch stakes route and validation
crates/minibf/src/routes/epochs/mod.rs, crates/minibf/src/lib.rs, docs/content/apis/minibf.mdx
Adds the route and handler. The handler validates epochs, scans and decodes stake logs, filters zero-stake records, applies pagination, maps response fields, and documents the endpoint. Tests cover success, pagination, empty epochs, invalid epochs, and storage failures.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

  • txpipe/dolos#1145: Introduces the AccountStakeLog data consumed by this endpoint.
  • txpipe/dolos#731: Uses related epoch-scoped Mini Blockfrost route and pagination patterns.
  • txpipe/dolos#736: Uses related stake-log retrieval and epoch data mapping patterns.

Suggested reviewers: scarmuega

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch mmahut/epoch-stakes

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Blockfrost-compatible /epochs/{epoch}/stakes support to the minibf service by serving per-account epoch stake distribution from the archived account-stakes log (emitted by Cardano RUPD), with pagination and tests.

Changes:

  • Implement /epochs/{epoch}/stakes route that scans AccountStakeLog entries for the epoch-start temporal key, filters zero-amount rows, and maps results to Blockfrost models.
  • Extend synthetic test seeding to write AccountStakeLog rows and add endpoint tests (happy path, pagination, empty epoch, 404/400, fault handling).
  • Document the new endpoint in the minibf API docs and register the route in the router.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
docs/content/apis/minibf.mdx Documents /epochs/{epoch}/stakes as a supported minibf endpoint.
crates/testing/src/synthetic.rs Adds a helper to seed per-epoch AccountStakeLog entries for integration tests.
crates/minibf/src/test_support.rs Seeds account-stake logs in the synthetic domain builder and adds a helper to compute tip epoch for tests.
crates/minibf/src/routes/epochs/mod.rs Implements the new /epochs/{epoch}/stakes handler and adds comprehensive route tests.
crates/minibf/src/lib.rs Wires the new endpoint into the Axum router.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +124 to +125
let pagination = Pagination::try_from(params)?;

Comment on lines +144 to +147
let inner = domain.inner.clone();
let skip = pagination.skip();
let count = pagination.count;

@mmahut
mmahut force-pushed the mmahut/epoch-stakes branch from d6ecc38 to 2e67328 Compare July 31, 2026 22:45
@mmahut mmahut added area:minibf Mini Blockfrost (minibf) API enhancement New feature or request labels Aug 6, 2026
@scarmuega
scarmuega requested a review from a team as a code owner August 13, 2026 10:52
@scarmuega
scarmuega force-pushed the mmahut/epoch-stakes branch 2 times, most recently from 319dee3 to bacef43 Compare August 13, 2026 11:54
Base automatically changed from mmahut/epoch-stake-log to main August 13, 2026 11:58
@scarmuega
scarmuega force-pushed the mmahut/epoch-stakes branch from bacef43 to 9b37f9f Compare August 13, 2026 11:58
@scarmuega
scarmuega merged commit aa85722 into main Aug 13, 2026
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:minibf Mini Blockfrost (minibf) API enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

minibf: add /epochs/<number>/stakes

3 participants